package club.zhcs.capture.bean;

import java.util.Date;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.lang.Times;

import club.zhcs.capture.qiniu.GJUploader;

import com.dgj.utils.db.data.Entity;

/**
 * 资料
 * 
 * @author Ixion
 *
 */
@Table("gj_material")
public class Material extends Entity {

	/**
	 * 资料类型
	 */
	@Column("m_type")
	@Comment("资料类型")
	private Type type;

	/**
	 * 序列号(二维码)
	 */
	@Column("m_serial")
	@Comment("资料序列号(二维码)")
	private String serial;

	/**
	 * 上传者id
	 */
	@Column("m_uploader_id")
	@Comment("上传者id")
	private int uploaderId;

	@Column("m_remark")
	@Comment("资料备注")
	@ColDefine(width = 1000)
	private String remark;

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * 文件路径
	 */
	@Column("m_file_path")
	@Comment("文件路径")
	@ColDefine(width = 100)
	private String filePath;
	/**
	 * 文件hash(用于避免重复上传)
	 */
	@Column("m_hash")
	@Comment("文件hash摘要")
	@ColDefine(width = 100)
	private String hash;

	/**
	 * 上传时间
	 */
	@Column("m_pload_time")
	@Comment("文件上传时间")
	private Date uploadTime = Times.now();

	/**
	 * 设备ID
	 */
	@Column("m_gather_device_id")
	@Comment("采集该资料的设备id")
	private String deviceId;

	public String getFileKey() {
		return fileKey;
	}

	public void setFileKey(String fileKey) {
		this.fileKey = fileKey;
	}

	/**
	 * 批次号
	 */
	@Column("m_uuid")
	@Comment("资料的批次号")
	private String batchNo;

	@Column("m_file_key")
	@Comment("文件存储在七牛的key")
	private String fileKey;

	@SuppressWarnings("unused")
	private String picPath;

	public String getPicPath() {
		return GJUploader.getUrl(fileKey);
	}

	/**
	 * 资料类型
	 * 
	 * @author Ixion
	 *
	 */
	public static enum Type {
		/**
		 * 财务
		 */
		FINANCE(1, "财务"),
		/**
		 * 文档
		 */
		DOC(2, "文档"),
		/**
		 * 身份证
		 */
		IDCARD(3, "身份证");
		private int id;
		private String name;

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		private Type(int id, String name) {
			this.id = id;
			this.name = name;
		}

	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public String getSerial() {
		return serial;
	}

	public void setSerial(String serial) {
		this.serial = serial;
	}

	public int getUploaderId() {
		return uploaderId;
	}

	public void setUploaderId(int uploaderId) {
		this.uploaderId = uploaderId;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}

	public Date getUploadTime() {
		return uploadTime;
	}

	public void setUploadTime(Date uploadTime) {
		this.uploadTime = uploadTime;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public String getBatchNo() {
		return batchNo;
	}

	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}

}
